package org.jmresler.sakila.batch.config;

import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

@Configuration
public class MetaDataSourceConfiguration {

    @Bean
    @ConfigurationProperties("spring.datasource.meta")
    public DataSourceProperties metaDataSourceProperties() {
        return new DataSourceProperties();
    }

    @Bean
    @Primary
    public DataSource metaDataSource() {
        return metaDataSourceProperties()
                .initializeDataSourceBuilder()
                .build();
    }

}
